using System;
using System.Collections;

namespace HtmlParser
{
	/// <summary>
	/// Summary description for AttributeCollection.
	/// </summary>
	public class AttributeCollection : CollectionBase
	{
		public AttributeCollection()
		{

		}

		public HtmlParser.Attribute this[int index]
		{
			get  
			{
				return((Attribute)List[index]);
			}
			set  
			{
				List[index] = value;
			}
		}
		
		public bool Contains(string name)
		{
			return IndexOf(name) != -1;
		}

		public int IndexOf(string name)
		{
			name = name.ToLower(	);
			for(int i = 0;i < this.Count; i++)
			{
				if(this[i].Name.ToLower() == name)
				{
					return i;
				}
			}

			return -1;
		}

		public HtmlParser.Attribute this[string name]
		{
			get
			{
				int index = IndexOf(name);
				if(index != -1)
				{
					return this[index];
				}

				return null;
			}
			set
			{
				int index = IndexOf(name);
				this[index] = value;
			}
		}

		public int Add(HtmlParser.Attribute value)  
		{
			return(List.Add(value));
		}

		public int IndexOf(HtmlParser.Attribute value)  
		{
			return(List.IndexOf(value));
		}

		public void Insert(int index, HtmlParser.Attribute value)  
		{
			List.Insert(index, value);
		}

		public void Remove(HtmlParser.Attribute value)  
		{
			List.Remove(value);
		}

		public bool Contains(HtmlParser.Attribute value)  
		{	
			return( List.Contains( value ) );
		}

	}
}
